package xh.lumt.server.commands.impl;


import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import xh.lumt.server.PlayingUpdateInfo;
import xh.lumt.server.ServerController;
import xh.lumt.server.commands.PlayerCommand;
import xh.lumt.server.commands.PlayerOperation;

/**
 * Created by Administrator on 2016/6/25.
 */
public class Play implements PlayerCommand {

    public PlayerOperation getPlayerOperation() {
        return PlayerOperation.Play;
    }

//    PlayingUpdateInfo pu = new PlayingUpdateInfo();

    private String url;
    private double fromSecond;

    public Object doCommand() {
        ServerController.getPlayStatusCenter().start(url, fromSecond);
        return null;
    }

    public void initFromParams(String[] params) {

        String json = params[params.length - 1];
        JSONObject jo = JSON.parseObject(json);


        url = jo.getString("src");
        fromSecond = jo.getDouble("playFrom");

//        pu.setMusicUrl(jo.getString("src"));
//        pu.setStartPlayFromSecond(jo.getInteger("playFrom"));
//        pu.setStartPlayTime(jo.getLong("startTime"));
    }

}
